<template>
  <div id="wrapper" style="padding: 20px">
    <div class="pageHeader">
      <el-page-header @back="goBack" content="详情页面">
      </el-page-header>
    </div>
    <el-card class="box-card">
      <el-descriptions title="禅道配置详情">
        <template slot="extra">
          <el-button @click="reset" type="primary" size="small">重置</el-button>
        </template>
        <el-descriptions-item label="禅道地址">{{ zentaoConfig.url }}</el-descriptions-item>
        <el-descriptions-item label="禅道用户名">{{ zentaoConfig.username }}</el-descriptions-item>
        <el-descriptions-item label="禅道密码">{{ zentaoConfig.password }}</el-descriptions-item>
      </el-descriptions>
    </el-card>
  </div>
</template>

<script>
  export default {
    name: 'zentaoConfigDetail',
    data() {
      return {
        zentaoConfig: {}
      }
    },
    methods: {
      async getZentaoConfig() {
        let res = await this.$http.get('/api/zentao/getConfig')
        this.zentaoConfig = res.data
      },
      goBack() {
        this.$router.push('/config')
      },
      async reset() {
        let res = await this.$http.post('/api/zentao/reset')
        if(res.code == 0){
          this.$message({
            message: res.message,
            type: 'success'
          })
          this.getZentaoConfig()
        }else {
          this.$message({
            message: res.message,
            type: 'error'
          })
        }
      }
    },
    created() {
      this.getZentaoConfig()
    }
  }
</script>

<style>
.pageHeader{
  padding: 10px;
}
</style>
